/**
* Copyright (C) 2008 Happy Fish / YuQing
*
* FastDFS may be copied only under the terms of the GNU General
* Public License V3, which may be found in the FastDFS source kit.
* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
**/

//client_io.h

#ifndef _CLIENT_IO_H
#define _CLIENT_IO_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <event.h>
#include "fnio_define.h"
#include "queue.h"
#include "server_io.h"

struct fnio_server_info;

struct fnio_client_info
{
	int client_sock;
	int last_server_conn_errno;  //avoid repeatly notify proxy client
	int64_t session_id;
	struct fnio_buff_node *pRecvNode;
	struct fnio_send_buff sbuff; //send buff to client

	struct event ev_read;
	struct event ev_write;
	bool sending;  //if in sending progress
	char client_ip[IP_ADDRESS_SIZE];
};

#ifdef __cplusplus
extern "C" {
#endif

int client_io_init(int server_sock);
int fnio_push_to_client_send_buff(struct fnio_server_info *pServerInfo);
int fnio_notify_server_conn_status(struct fnio_server_info *pServer);

#ifdef __cplusplus
}
#endif

#endif

